import axios from '@/utils/request'
const base = '/userserver'

export function login(data) {
  return axios({
    url: `${base}/users/token`,
    method: 'post',
    data
  })
}

export function getInfo() {
  return axios({
    url: `${base}/users/info`,
    method: 'get'
  })
}

export function logout() {
  return axios({
    url: `${base}/users/info`,
    method: 'post'
  })
}

export function listUser(params) {
  return axios({
    url: `${base}/users`,
    method: 'get',
    params: params
  })
}

export function saveUser(data) {
  return axios({
    url: `${base}/users`,
    method: 'post',
    data
  })
}

export function modifyUser(id, data) {
  return axios({
    url: `${base}/users/` + id,
    method: 'put',
    data
  })
}

export function resetPwd(id) {
  return axios({
    url: `${base}/users/` + id + '/defaultPwd',
    method: 'put'
  })
}

export function modifyAccount(data) {
  return axios({
    url: `${base}/users/account`,
    method: 'put',
    data
  })
}

export function modifyPassword(data) {
  return axios({
    url: `${base}/users/password`,
    method: 'put',
    data
  })
}

export function nickname(data) {
  return axios({
    url: `${base}/users/nickname`,
    method: 'put',
    data
  })
}

export function enable(id) {
  return axios({
    url: `${base}/users/` + id + '/enable',
    method: 'put'
  })
}

export function disable(id) {
  return axios({
    url: `${base}/users/` + id + '/disable',
    method: 'put'
  })
}
